/*
Copyright (C) 2021-2025 Casa Xu (also Zhiyan Xu) from HIT

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/*
 * LOS_NaviEnhance.h
 *
 *  Created on: 2022年7月17日
 *      Author: 64435
 */

#ifndef PERIPHERAL_LAYER_INC_LOS_NAVIENHANCE_H_
#define PERIPHERAL_LAYER_INC_LOS_NAVIENHANCE_H_

#include "LOS_CAN.h"
#include "LOS_SYS.h"

typedef struct LOS_NaviEnhance_t
{
    /* 健康管理状态量 */
    uint8_t VAL;                 //数据有效性标志，0：有效， 其他值：无效
    uint8_t CMD;                 //开关机指令状态,发送开机指令后置1，发送关机指令后置0
    uint8_t PWR;                 //电源状态，读取电源遥测，通电为1，断电为0
    uint8_t MSG;                 //通信状态，通信正常为0，通信异常为其他值
    uint8_t SWNUM;
    uint8_t HL_TXF;              //HL_前缀表示健康管理相关变量。遥测请求发送完成标志,发送一次后该量置1，接收到回应后置0(TX FINISHED)
    uint8_t HL_WCNT;             //等待接收计数器。该计数器在操作系统的一个线程中累加，当HL_TXF为1时该值+1，HL_TXF为0时该值清0，当累加到一定值时系统会判断通信异常，并将MSG置1
    /*  */
    uint8_t TM_Type;             //请求遥测类型，0：短包  1：长包

}LOS_NaviEnhance_t;

extern LOS_NaviEnhance_t STA_NaviEnhance;

extern uint8_t NaviEnhance_CMD_Status[3];  //基本状态遥测轮询指令
extern uint8_t NaviEnhance_CMD_Result[3];  //运算结果遥测轮询指令
extern uint8_t navi_test_flag;
extern uint8_t navi_dabuf[370];

void LOS_NaviEnhance_CMD(uint8_t *cmd);
void LOS_NaviEnhance_OriginData(uint8_t *odata);
//void LOS_NaviEnhance_Test();
void LOS_NaviEnhance_Star();
void LOS_CAN_NaviEnhanceCallBack(LOS_CANMSG_t* can_re);
void LOS_NaviEnhance_DataTest();
void LOS_NaviEnhance_UP();
void LOS_NaviEnhance_PWROn();
void LOS_NaviEnhance_PWROff();

#endif /* PERIPHERAL_LAYER_INC_LOS_NAVIENHANCE_H_ */
